import observermode.subject.Zh0202BookStore;
import observermode.subject.Zh0202MySubject;
import statemode.context.Zh0202User;
import statemode.state.Zh0202Level;
import statemode.state.Zh0202OrdinaryMember;

/**
 * @author: zh
 * @date: 2021/11/18 11:30
 * @version: 1.0
 */
public class Client {
    public static void main(String[] args) {
        //注册用户基本信息
        Zh0202User user = new Zh0202User("张涵");
        Zh0202Level level = new Zh0202OrdinaryMember(user);
        user.setUserLevel(level);
        //购买图书
        user.buyBook();
        System.out.println("---------------------------");
        user.buyBook();
        System.out.println("---------------------------");
        user.buyBook();
        System.out.println("---------------------------");
        user.buyBook();
        //注册商家
        Zh0202MySubject store = new Zh0202BookStore();
        store.addObserver(user);
        store.sendMsg();
        //用户兑换
        user.changeCredit();
    }
}
